<?php 
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
		<div id='header'>

		<!-- Title -->
		<br/><br/><br/><br/><br/><br/><br/>

			<!-- Login -->
			<div id='login-panel'>
				<?php
					if (isset($_SESSION['user']) && is_numeric($_SESSION['user'])) {
						//Get user
						$result = mysql_query("SELECT * FROM users WHERE id='" . $_SESSION['user'] . "'");
						$login_user	= mysql_fetch_array($result);

						//Get avatar
						$login_avatar = "/deviantpic/picture/files/unknown.jpg";
						if ($login_user['avatar_id'] > 0) {
							$result = mysql_query("SELECT photo FROM photos WHERE id='" . $login_user['avatar_id'] . "'");
							$row	= mysql_fetch_array($result);
							$login_avatar	= $row['photo'];
						}
				?>
				<div id="login-avatar"><img alt="avatar" width="48" height="48" src=<?php echo '"' . $login_avatar . '"'; ?> /></div>
				<div id="login-name">
					Welcome,
					<span class="login-name">
						<?php echo '<a href= "/deviantpic/user/profile/index.php?id=' . $_SESSION['user'] . '">' . $login_user['username'] . '</a>'; ?>
					</span>!
				</div>
				<div id="upload-link"><a href="/deviantpic/picture/upload.php">upload</a></div>
				<div id="logout"><a href="/deviantpic/user/logout.php">logout</a></div>
				<?php
					} else {
				?>
				<form action='/deviantpic/user/login.php' method='post'><p>
					<label for='login_user' >Username: </label>		<input type='text' id='login_user' name='user'/> <br />
					<label for='login_password' >Password: </label>	<input type='password' id='login_password' name='password'/> <br />
					<input type='submit' value='Login' />
				</p></form>

				<!-- Register link -->
				<div id='register'>
					Not a user? Register <a href='/deviantpic/user/register.php'>here</a>!
				</div>
				<?php
					}
				?>
			</div>

			<!-- Search -->
			<div id='search'>
				<!-- Pictures -->
				<form action='/deviantpic/picture/search.php' method='get'><p>
					<label for='search_picture' >Search pictures: </label> <input type='text' id='search_picture' name='picture'/>
					<input type='submit' value='Go' />
				</p></form>

				<!-- Users -->
				<form action='/deviantpic/user/search.php' method='get'><p>
					<label for='search_user' >Search users: </label> <input type='text' id='search_user' name='user'/>
					<input type='submit' value='Go' />
				</p></form>
			</div>
		</div>
